import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:i18n_demo/i18n_Localizations.dart';
class GYLocalizeationsDelegate extends LocalizationsDelegate {
  static GYLocalizeationsDelegate delegate = GYLocalizeationsDelegate();
  //用于当前环境的Local，是否在我们支持的语言范围
  @override
  bool isSupported(Locale locale) {
    //判断传递进来的Local对象是否在我们支持范围内
   return ["en","zh"].contains(locale.languageCode);
  }
  //当Locale发生改变时（语言环境），加载对应的HYLocalizations资源
  @override
  Future load(Locale locale) {
    return SynchronousFuture(GYLocalizations(locale));
  }
  //当Localizations Widget重新build时，是否调用load方法去重新加载Local资源
  @override
  bool shouldReload(covariant LocalizationsDelegate old) {
    return false; //这里不用去重新加载，具体看使用场景
  }
  
}